package com.yixun.qfbao.hander;

import com.yixun.qfbao.api.service.ReportModelApiService;
import com.yixun.qfbao.apidto.MoveReportModelOrderReqDto;
import com.yixun.qfbao.apidto.MoveReportModelOrderResDto;
import com.yixun.qfbao.dto.base.BaseRequestDTO;
import com.yixun.qfbao.dto.base.BaseResponseDTO;
import com.yixun.qfbao.hander.base.CommonAbstractHander;
import com.yixun.qfbao.util.exception.TServerException;
import com.yixun.qfbao.vo.MoveReportModelOrderReqVo;
import com.yixun.qfbao.xf.model.enums.ResultEnum;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class MoveReportModelOrderHander  extends CommonAbstractHander{
    private static Logger logger= LoggerFactory.getLogger(MoveReportModelOrderHander.class);
    @Autowired
    private ReportModelApiService reportModelApiService;

    @Override
    public BaseResponseDTO doBusiness(BaseRequestDTO reqDto) {
        MoveReportModelOrderReqVo req = (MoveReportModelOrderReqVo)reqDto;
        MoveReportModelOrderReqDto reqDto1 = req.getParams();
        BaseResponseDTO<MoveReportModelOrderResDto> res = new BaseResponseDTO<MoveReportModelOrderResDto>();
        MoveReportModelOrderResDto resDto = new MoveReportModelOrderResDto();
        try {
            resDto = reportModelApiService.moveReportModelOrder(reqDto1);
        }catch(TServerException e){
            resDto.setResult(ResultEnum.FAIL.getNo());
            resDto.setResultMsg(e.getErrorMsg());
        } catch (Exception e) {
            logger.error("MoveReportModelOrderHander error: {}", e);
            resDto.setResult(ResultEnum.FAIL.getNo());
            resDto.setResultMsg("系统异常");
        }
        res.setResData(resDto);
        res.setResult(resDto.getResult());
        res.setErrorMsg(resDto.getResultMsg());
        return res;
    }
}
